home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
DOUBLEDE
/
PRINT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-27
|
2KB
|
115 lines
#include <PrintMgr.h>
#include <WindowMgr.h>
#include <DialogMgr.h>
#include <QuickDraw.h>
#include <ToolboxUtil.h>
#define NIL 0L
static THPrint hPrint;
/*====================================================================
CheckPrintHandle()
allocate print handle if not already done
====================================================================*/
CheckPrintHandle()
{
if (!hPrint)
PrintDefault(hPrint = (TPrint **) NewHandle( sizeof( TPrint )));
}
/*====================================================================
dopagesetup()
allow user to do Page Setup dialog
====================================================================*/
dopagesetup()
{
InitCursor();
PrOpen();
CheckPrintHandle();
if (PrStlDialog(hPrint)) ;
PrClose();
}
/*====================================================================
HowMany()
returns the number of copies of the document are desired.
====================================================================*/
HowMany()
{
return( ((**hPrint).prJob.bJDocLoop==bDraftLoop) ?
(**hPrint).prJob.iCopies : 1 );
}
/*====================================================================
print_it()
prints to the printer, a QuickDraw routine should replace the
default routine included
====================================================================*/
print_it()
{
TPPrPort printPort;
TPrStatus prStatus;
Rect pRect;
int nCopies;
GrafPtr tempPort;
int tFont;
int tSize;
InitCursor();
GetPort(&tempPort);
tFont = tempPort->txFont;
tSize = tempPort->txSize;
PrOpen();
if (PrError() == noErr){
/* make sure we have
a valid print handle */
CheckPrintHandle();
/* do job dialog */
if (PrJobDialog(hPrint) != 0) {
/* print the number
of copies requested */
for(nCopies=HowMany(); nCopies>0; nCopies--){
printPort = PrOpenDoc(hPrint,0L,0L);
SetPort(printPort);
TextFont(tFont);
TextSize(tSize);
PrOpenPage(printPort,0L);
pRect = (**hPrint).prInfo.rPage;
TextFont(tFont);
TextSize(tSize);
/*
your drawing procedure should be called here
*/
MoveTo(pRect.left+4,pRect.top+15);
DrawString("\pNo LightspeedC Shell Print Routine Installed");
PrClosePage(printPort);
PrCloseDoc(printPort);
PrPicFile(hPrint,0L,0L,0L,&prStatus);
}
}
}
PrClose();
SetPort(tempPort);
}